package com.yusvn.scm.common.interceptor;

import javax.servlet.http.HttpServletResponse;

import com.jfinal.aop.Interceptor;
import com.jfinal.aop.Invocation;

/**
 * 跨域浏览器，暂未使用，使用JFinal中的CorsInterceptor
 * @author liugz
 *
 */
public class CorsInterceptor implements Interceptor {
	 
	/*
	 * 支持跨域访问
	 */
    @Override
    public void intercept(Invocation inv) {
        inv.invoke();
        HttpServletResponse response = inv.getController().getResponse();
        response.setContentType("application/json;charset=UTF-8");
        response.setHeader("Access-Control-Allow-Origin", "*");
        //response.setHeader("Access-Control-Allow-Credentials", "true");
        response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE, PUT, HEAD");
        response.setHeader("Access-Control-Max-Age", "3600");
        //response.setHeader("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With, remember-me"); //Origin,X-Requested-With,Content-Type,Accept
        response.setHeader("Access-Control-Allow-Headers", "Content-Type, Accept, x-requested-with, X-Custom-Header, Authorization");
        
    }
    
    
    
}